using UnityEngine;

namespace AutoChess
{
    class GoDummyPoint
    {
        private Transform m_goRootTrans = null;
        
        private Transform[] m_dummyCache = new Transform[(int)DummyPoint.DM_S_MAX];
        private bool[] m_dummyCacheValid = new bool[(int) DummyPoint.DM_S_MAX];
        
        public GoDummyPoint()
        {
            for (int i = 0; i < m_dummyCacheValid.Length; i++)
            {
                m_dummyCacheValid[i] = false;
            }
        }

        public Transform GetDummyPoint(DummyPoint dummyPoint)
        {
            if (dummyPoint == DummyPoint.DM_S_NONE || m_goRootTrans == null)
            {
                return null;
            }

            int index = (int) dummyPoint;
            if (index >= 0 && index < m_dummyCacheValid.Length)
            {
                if (!m_dummyCacheValid[index])
                {
                    m_dummyCacheValid[index] = true;
                    var dummyTrans =
                        BUnityUtil.FindChildByName(m_goRootTrans, AvatarDefine.GetDummyPointName(dummyPoint));
                    /*if (dummyTrans == null)
                    {
                        BLogger.EditorWarning("there no DummpyPoint:[{0}] created!", dummyPoint);
                    }*/

                    return dummyTrans;
                }
                else
                {
                    return m_dummyCache[index];
                }
            }

            return null;
        }

        public void Refersh(Transform goTrans)
        {
            
        }
    }
}